import React, { Component } from 'react'
import MyContext from './MyContext'
import CommonContext from './CommonContext'

export default class Grandson extends Component {

  // static contextType = MyContext;

  render() {
    return (
      <div>
        {/* {this.context} */}
        <MyContext.Consumer>
          {
            ({name,age,title}) => {
              console.log('MyContext.Consumer:', name,age)
              return (<>
                name： {name} age:{age}
              
                <CommonContext.Consumer>
                  {
                    ({title}) => {
                      return <h1>title:{title}</h1>
                    }
                  }
                </CommonContext.Consumer>

              </>
              )
            }
          }
        </MyContext.Consumer>

      </div>
    )
  }


  componentDidMount() {
    // console.log(this.context)
  }
}
